home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / S9303.ZIP;1 / SPENCE.ZIP / ABROWSER.PRG < prev    next >
Encoding:
Text File  |  1993-01-05  |  1.2 KB  |  36 lines

  1. // Abrowser.prg
  2. //
  3. // Returns TBrowse object fully configured to browse an array
  4.  
  5. #include "Abrowser.ch"
  6.  
  7. FUNCTION ABrowseNew()
  8.  
  9. LOCAL oTbr := TBrowseNew()
  10.  
  11.   // We use cargo as a 2 element array:
  12.   //   The first is the index to array we are browsing
  13.   //   The second is a pointer to the array
  14.   // Abrowser.ch contains two definitions that translate
  15.   // :arrayIndex and :arrayReference into these elements
  16.   // - just makes the code a bit more readable
  17.   
  18.   oTbr:cargo := Array(2)
  19.  
  20.   oTbr:arrayIndex    := 1
  21.   oTbr:goTopBlock    := {|| oTbr:arrayIndex := 1 }
  22.   oTbr:goBottomBlock := {|| oTbr:arrayIndex := Len(oTbr:arrayReference) }
  23.  
  24.   // Standard array skipper
  25.   oTbr:skipBlock     := {|nToSkip, nTemp| ;
  26.                           nTemp := oTbr:arrayIndex, ;
  27.                           oTbr:arrayIndex := ;
  28.                             iif(nToSkip > 0, ;
  29.                                 Min(oTbr:arrayIndex + nToSkip,      ;
  30.                                     Len(oTbr:arrayReference)),      ;
  31.                                 Max(1, oTbr:arrayIndex + nToSkip)), ;
  32.                           oTbr:arrayIndex - nTemp                   ;
  33.                           }
  34.  
  35. RETURN oTbr
  36.